// pages/user/amounttail.js
const config = require('../../config')
const util = require('../../utils/util')
var app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
    
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getWithDraw()
    },
    getWithDraw: function (){

        var that = this
        if (app.globalData.uid) {
            var headerkey = util.createheaderkey()
            wx.request({
                url: config.host + '/api/getwish/getWithDraw',
                method: 'GET',
                header: {
                    'content-type': 'application/json',
                    'key': headerkey.key,
                    'time': headerkey.timestamp
                },
                data: {
                    uid: app.globalData.uid
                },
                success: function (res) {
                    if (res.data.code == 200) {
                        var data = res.data.data
                        
                        that.setData({
                            all_count: data.all_count,
                            count: data.count,
                            listData: data.listData
                        })
                    } else {
                        wx.showModal({
                            title: '失败',
                            content: res.data.msg,
                            showCancel: false
                        })
                    }
                },
                fail: function (res) {
                    wx.showToast({
                        title: '明细列表获取失败!',
                        duration: 3000
                    })
                }
            })
        } else {
            setTimeout(function () {
                that.getWithDraw()
            }, 1000)
        }
    }
})